package com.xixun.rainfall.ui;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.xixun.rainfall.App;

/**
 * @Author： LJH
 * @Time： 2024/6/12
 * @description：
 */
public class MainViewModel extends ViewModel {
    private MutableLiveData<String> waterLevelLiveData = new MutableLiveData<String>(App.getApp().waterLevel());
    private MutableLiveData<String> hourlyRainfallLiveData = new MutableLiveData<String>(App.getApp().hourlyRainfall());
    private MutableLiveData<String> dailyRainfallLiveData = new MutableLiveData<String>(App.getApp().dailyRainfall());

    /**
     * 刷新水位数据
     * @param newWaterLevel
     */
    public void changeWaterLevel(String newWaterLevel) {
        waterLevelLiveData.postValue(newWaterLevel);
    }

    /**
     * 刷新小时雨量
     * @param newHourlyRainfall
     */
    public void changeHourlyRainfall(String newHourlyRainfall) {
        hourlyRainfallLiveData.postValue(newHourlyRainfall);
    }

    /**
     * 刷新今日雨量
     * @param newDailyRainfall
     */
    public void changeDailyRainFall(String newDailyRainfall){
        dailyRainfallLiveData.postValue(newDailyRainfall);
    }


    public MutableLiveData<String> getWaterLevelLiveData() {
        return waterLevelLiveData;
    }

    public MutableLiveData<String> getHourlyRainfallLiveData() {
        return hourlyRainfallLiveData;
    }

    public MutableLiveData<String> getDailyRainfallLiveData() {
        return dailyRainfallLiveData;
    }
}
